<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>纯 CSS 实现瀑布流式排版</title>
</head>
<body>
    <div class="container">
        <div class="item" style="height: 140px"></div>
        <div class="item" style="height: 190px"></div>
        <div class="item" style="height: 170px"></div>
        <div class="item" style="height: 120px"></div>
        <div class="item" style="height: 160px"></div>
        <div class="item" style="height: 180px"></div>
        <div class="item" style="height: 140px"></div>
        <div class="item" style="height: 150px"></div>
        <div class="item" style="height: 170px"></div>
        <div class="item" style="height: 170px"></div>
        <div class="item" style="height: 140px"></div>
        <div class="item" style="height: 190px"></div>
        <div class="item" style="height: 170px"></div>
        <div class="item" style="height: 120px"></div>
        <div class="item" style="height: 160px"></div>
        <div class="item" style="height: 180px"></div>
        <div class="item" style="height: 140px"></div>
        <div class="item" style="height: 150px"></div>
        <div class="item" style="height: 170px"></div>
        <div class="item" style="height: 170px"></div>
        
        <span class="item break"></span>
        <span class="item break"></span>
        <span class="item break"></span>
      </div>
</body>
<style>
    .container{
        display: grid;
        grid-template-columns: repeat(4,1fr);
        grid-gap: 10px;
        /* 下面的属性兼容性不好 */
        grid-template-rows: masonry;
    }
    .item {
        margin-bottom: 2%;
        border-radius: 3px;
        background-color: #a1cbfa;
        border: 1px solid #4290e2;
        box-shadow: 0 2px 2px rgba(0,90,250,0.05),
            0 4px 4px rgba(0,90,250,0.05),
            0 8px 8px rgba(0,90,250,0.05),
            0 16px 16px rgba(0,90,250,0.05);
        color: #fff;
        padding: 15px;
        box-sizing: border-box;
    }
</style>
</html>